<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>帐号管理</title>
	<%@ include file="/common/meta.jsp" %>
	<link href="${ctx}/css/yui.css" type="text/css" rel="stylesheet"/>
	<link href="${ctx}/css/style.css" type="text/css" rel="stylesheet"/>
	<link href="${ctx}/js/validate/jquery.validate.css" type="text/css" rel="stylesheet"/>
	<script src="${ctx}/js/validate/jquery.validate.js" type="text/javascript"></script>
	<script src="${ctx}/js/validate/messages_cn.js" type="text/javascript"></script>
	<script>
		$(document).ready(function() {
			//聚焦第一个输入框
			$("#loginName").focus();
			//为inputForm注册validate函数
			$("#inputForm").validate({
				rules: {
					loginName: {
						required: true,
						remote: "user!checkLoginName.action?oldLoginName=" + encodeURIComponent('${loginName}')
					},
					name: "required",
					email:"email",
					checkedRoleIds:"required"
				},
				messages: {
					loginName: {
						remote: "用户登录名已存在"
					}
				}
			});
			
		});
		
		function search(){
		var gender = null;
		var className;
		if($("#loginName").val()!=""){
			$.getJSON("user!sychPerson.action?loginName="+encodeURIComponent($("#loginName").val()),function(json){
			$("#pInformation").html("");
			if(0==json.gender){
			 gender = "男";
			}else{
			 gender = "女";
			}
			
			if(null==json.clazz){
			 className="";
			}else{
			 className=json.clazz.className;
			}
			$("#pInformation").append(
			"<tr>"
			+"<td>"+"用户名:"+"</td>"
			+"<td>"+"<input type='text' name='name' value='"+json.name+"' disabled='disabled'/>"+"</td>"
            +"<td>"+"性别:"+"</td>"
			+"<td>"+"<input type='text' name='gender' value='"+gender+"' disabled='disabled'/>"+"</td>"
			+"</tr>"
			+"<tr>"
			+"<td>"+"学/职工号:"+"</td>"
			+"<td>"+"<input type='text' name='idNumber' value='"+json.idNumber+"' disabled='disabled'/>"+"</td>"
            +"<td>"+"名族:"+"</td>"
			+"<td>"+"<input type='text' name='nationality' value='"+json.nationality+"' disabled='disabled'/>"+"</td>"
			+"</tr>"
			+"<tr>"
			+"<td>"+"出生年月:"+"</td>"
			+"<td>"+"<input type='text' name='birthday' value='"+json.birthday+"' disabled='disabled'/>"+"</td>"
			+"<td>"+"班级:"+"</td>"
			+"<td>"+"<input type='text' name='clazz' value='"+className+"' disabled='disabled'/>"+"</td>"
			+"</tr>"
			);
			});
			
			}
		}
	</script>
</head>

<body>
<div id="doc3">
<div id="bd">
	<div id="yui-main">
	<div class="yui-b">
	<h2><s:if test="id == null">创建</s:if><s:else>修改</s:else>用户</h2>
	<form id="inputForm" action="user!save.action" method="post">
		<input type="hidden" name="id" value="${id}"/>
		<table class="noborder">
			<tr>
				<td>登录名:</td>
				<td colspan="7"><input type="text" name="loginName" size="40" id="loginName" value="${loginName}" onchange="search()"/></td>
			</tr>
			<tr>
				<td>用户名:</td>
				<td colspan="7"><input type="text" id="name" name="name" size="40" value="${name}"/></td>
			</tr>
			<tr>
				<td>角色:</td>
				<td colspan="7">
					<s:checkboxlist name="checkedRoleIds" list="allRoleList" listKey="id" listValue="name" theme="simple"/>
				</td>
			</tr>
			</table>
			
			<table id="pInformation" class="noborder">
			
			</table>
			
			<table class="noborder">
			<tr>
				<td colspan="8">
					<input class="button" type="submit" value="提交"/>&nbsp;
					<input class="button" type="button" value="返回" onclick="history.back()"/>
				</td>
			</tr>
		</table>
	</form>
	</div>
	</div>
</div>
</div>
</body>
</html>
